﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ProductDetails.ascx.cs" Inherits="ShopOnline.Controls.ProductDetails" %>

<%@ Register Assembly="ShopOnline" Namespace="ShopOnline.Controls" TagPrefix="uc" %>
<%@ Register Src="~/Controls/Common/LightBoxGallery.ascx" TagName="LightBoxGallery" TagPrefix="uc" %>
<%@ Register Src="~/Controls/Common/FBLikeButton.ascx" TagName="FBLikeButton" TagPrefix="uc" %>
<%@ Register Src="~/Controls/Common/GoogleButton.ascx" TagName="GoogleButton" TagPrefix="uc" %>

<script type="text/javascript">
    function btnAddCart_click(id) {
        $('#<%= hidID.ClientID %>').val(id);
        $('#<%= btnAddCart.ClientID %>').click();
    }

    function btnAddWishList_click(id) {
        $('#<%= hidID.ClientID %>').val(id);
        $('#<%= btnAddWishList.ClientID %>').click();
    }

    function openWindow(url) {
        wnd_gallery.navigateUrl = url;
        wnd_gallery.title = "Gallery";
        wnd_gallery.open();
    }

    function choosePic(a) {
        $('#<%= ((Image)frmProduct.FindControl("imgPicture")).ClientID %>').attr('src', $(a).find("img").attr('real'));
    }

    $(document).ready(function () {
        $('.galleryItem').click(function () {
            $('.galleryItemSelected').removeClass('galleryItemSelected');
            $(this).addClass('galleryItemSelected');
            $('#<%= ((HiddenField)frmProduct.FindControl("hidSelectedPic")).ClientID %>').val($(this).attr('imgid'));
        });
    });

    function addProductToCart(id) {
        var picID = $('#<%= ((HiddenField)frmProduct.FindControl("hidSelectedPic")).ClientID %>').val();
        window.location = "Cart.aspx?id=" + id + '&pic=' + picID;
    }
</script>

<uc:WindowManager ID="windowManager" runat="server" />
<uc:Window ID="gallery" runat="server" URL="Default.aspx" Title="A" WindowWidth="660" WindowHeight="500" AllowResizing="false" AllowScrolling="false" />

<asp:FormView ID="frmProduct" runat="server" Width="100%">
    <ItemTemplate>
        <asp:HiddenField Value='<%# GetPictureID() %>' ID='hidSelectedPic' runat="server" />
        <table cellpadding="5" cellspacing="0" width="100%">
            <tr>
                <td style='vertical-align: top; text-align: left;width:260px;'>
                    <a href="#" onclick='<%# "openWindow(\"SlideShow.aspx?id=" + ((HiddenField)frmProduct.FindControl("hidSelectedPic")).Value + "\"); return false;"%>'>
                        <asp:Image align="left" ID="imgPicture" ImageUrl='<%# GetPicture() %>' runat="server" Style="width:250px; height:auto; margin-right:4px; margin-bottom:4px; max-height:275px" />
                    </a>
                    <br style='clear:both' />
                        <uc:LightBoxGallery ID="gallery" runat="server" RepeatColumns="4" RepeatLayout="Table" OriginalField="OriginalUrl" ThumbField="ThumbUrl" DescriptionField="Description" IDField="ID" />
                </td>
                <td style='vertical-align: top; text-align: left;' valign="top">
                    <h2><asp:Label class='productDetailTitle' ID="lblProductName" runat="server" Text='<%#  GetProductName() %>' ></asp:Label></h2>
                    <div style='height:10px'> &nbsp;</div>
                    <asp:Literal ID="litRegularPrice" runat="server" Text='<%# GetRPPPrice() %>' ></asp:Literal>

                    <div style='height:10px'> &nbsp;</div>

                    <asp:Label Font-Bold="true" class="productDetailLabel" ID="Label1" runat="server">Your price: </asp:Label>
                    <asp:Label Font-Bold="true" class="productDetailLabel" ID="lblProductPrice" ForeColor="Red"
                        runat="server" Text='<%# GetPrice() %>' ></asp:Label>
                    &nbsp;&nbsp;
                    <asp:Label Font-Bold="true" class="productDetailLabel" ID="Label3" runat="server">Status: </asp:Label>
                    <asp:Label Font-Bold="true" class="productDetailLabel" ID="lblStatus" runat="server" Text='<%# GetStatus() %>' ></asp:Label>
                    
                    <div style='height:20px'> &nbsp;</div>

                    <div style="float:left;" >
                        <button id="Button1" type="button" runat="server" onclick='<%# "btnAddCart_click(" +  Eval("ID").ToString() + ");" %>' title="You can select the style you want to purchase by clicking on the picture beside." class="button btn-cart">
                        <span><span>Add to Cart</span></span></button>

                        <button id="Button2" type="button" runat="server" onclick='<%# "btnAddWishList_click(" +  Eval("ID").ToString() + ");" %>' title="Add to your wishlist." class="button btn-cart">
                        <span><span>Add to Wishlist</span></span></button>
                    </div>
                    <div style='height:40px; clear:both;'> &nbsp;</div>
                    <asp:Label Font-Bold="true" class="productDetailLabel" ID="Label2" runat="server">Quick Overview: </asp:Label>
                    <asp:Literal ID="litDescription" runat="server" Text='<%# Eval("Description") == DBNull.Value ? "<span class=\"labelTitle\">n/a</span>" : "<span class=\"labelTitle\">" + Eval("Description").ToString().Replace("\r", "<br/>").Replace("\n", "<br/>") + "</span>" %>'></asp:Literal>
                    <div style="padding-top:20px" align="right">
                        <uc:FBLikeButton runat="server" ID="ucFBLikeButton" />
                        <uc:GoogleButton runat="server" ID="ucGoogleButton" />
                    </div>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:FormView>

<asp:HiddenField ID="hidID" runat="server" />
<asp:Button ID="btnAddCart" runat="server" OnClick="btnAddCart_OnClick" style='display:none' />
<asp:Button ID="btnAddWishList" runat="server" OnClick="btnAddWishList_OnClick" style='display:none' />